package com.j283_5.wisdom_park.controller.property_overview;


import com.j283_5.wisdom_park.common.result.ResultData;
import com.j283_5.wisdom_park.service.PropertyOverviewService;
import com.j283_5.wisdom_park.vo.property_overview.ChartVo;
import com.j283_5.wisdom_park.vo.property_overview.ErrorCauseAnalysisVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 蒋翔
 * @since 2022-04-28
 */
@RestController
@RequestMapping("/propertyOverview")
@Api(value = "物业总览",tags = "物业总览",produces="蒋翔")
public class PropertyOverviewController {

    @Resource
    private PropertyOverviewService propertyOverviewService;

    @RequestMapping(value = "/numberOfEquipmentInNormal" , method = RequestMethod.GET)
    @ApiOperation(value = "正常运行设备数量",notes = "正常运行设备数量（台）",produces="蒋翔", response = ResultData.class)
    public ResultData numberOfEquipmentInNormal(){
        //return ResultData.ok().data(1354);
        return propertyOverviewService.numberOfEquipmentInNormal();
    }


    @RequestMapping(value = "/annualAccumulativePayment" , method = RequestMethod.GET)
    @ApiOperation(value = "年度累计缴费",notes = "年度累计缴费（元）",produces="蒋翔", response = ResultData.class)
    public ResultData annualAccumulativePayment(){
        //return ResultData.ok().data(638945.43);
        return propertyOverviewService.annualAccumulativePayment();
    }

    @RequestMapping(value = "/numberOfPeopleEntering" , method = RequestMethod.GET)
    @ApiOperation(value = "今日进出人数",notes = "今日进出人数（人）",produces="蒋翔", response = ResultData.class)
    public ResultData numberOfPeopleEntering(){
        //return ResultData.ok().data(5388);
        return propertyOverviewService.numberOfPeopleEntering();
    }

    @RequestMapping(value = "/IncomingAndOutgoingToday" , method = RequestMethod.GET)
    @ApiOperation(value = "今日进出车辆",notes = "今日进出车辆（辆）",produces="蒋翔", response = ResultData.class)
    public ResultData incomingAndOutgoingToday (){
        //return ResultData.ok().data(469);
        return propertyOverviewService.incomingAndOutgoingToday();
    }

    @RequestMapping(value = "/proportionOfDevicesByCategory" , method = RequestMethod.GET)
    @ApiOperation(value = "设备分类占比",notes = "设备分类占比",produces="蒋翔", response = ResultData.class)
    public ResultData proportionOfDevicesByCategory(){
        ChartVo chartVo1 = new ChartVo("人脸面板",211);
        ChartVo chartVo2 = new ChartVo("车辆道闸",167);
        ChartVo chartVo3 = new ChartVo("智能电表",152);
        ChartVo chartVo4 = new ChartVo("视频监控",198);
        ArrayList<ChartVo> chartVos = new ArrayList<>();
        chartVos.add(chartVo1);
        chartVos.add(chartVo2);
        chartVos.add(chartVo3);
        chartVos.add(chartVo4);
        return  ResultData.ok().data(chartVos);
    }

    @RequestMapping(value = "/propertyPayCost" , method = RequestMethod.POST)
    @ApiOperation(value = "物业缴费",notes = "物业缴费",produces="蒋翔", response = ResultData.class)
    public ResultData propertyPayCost (Integer way){
//        ArrayList<ChartVo> chartVos = new ArrayList<>();
//        for(int i=1 ; i< 13 ; i++){
//
//            int n = (int)(Math.random()*901+200);
//            ChartVo chartVo = new ChartVo((i+"月"),n);
//            chartVos.add(chartVo);
//        }
//        return ResultData.ok().data(chartVos);
        return propertyOverviewService.propertyPayCost(way,0);
    }

    @RequestMapping(value = "/publicResources" , method = RequestMethod.POST)
    @ApiOperation(value = "公共资源",notes = "公共资源",produces="蒋翔", response = ResultData.class)
    public ResultData publicResources (Integer way){
//        ArrayList<ChartVo> chartVos = new ArrayList<>();
//        for(int i=1 ; i< 13 ; i++){
//
//            int n = (int)(Math.random()*901+200);
//            ChartVo chartVo = new ChartVo((i+"月"),n);
//            chartVos.add(chartVo);
//        }
//        return ResultData.ok().data(chartVos);

        return propertyOverviewService.propertyPayCost(way,1);
    }

    @RequestMapping(value = "/carPayment" , method = RequestMethod.POST)
    @ApiOperation(value = "车辆缴费",notes = "车辆缴费",produces="蒋翔", response = ResultData.class)
    public ResultData carPayment (Integer way){
//        ArrayList<ChartVo> chartVos = new ArrayList<>();
//        for(int i=1 ; i< 13 ; i++){
//
//            int n = (int)(Math.random()*901+200);
//            ChartVo chartVo = new ChartVo((i+"月"),n);
//            chartVos.add(chartVo);
//        }
//        return ResultData.ok().data(chartVos);
        return propertyOverviewService.carPayment(way);
    }

    @RequestMapping(value = "/waterAndElectricityExpends" , method = RequestMethod.POST)
    @ApiOperation(value = "水电缴费",notes = "水电缴费",produces="蒋翔", response = ResultData.class)
    public ResultData waterAndElectricityExpends (Integer way){
//        ArrayList<ChartVo> chartVos = new ArrayList<>();
//        for(int i=1 ; i< 13 ; i++){
//
//            int n = (int)(Math.random()*901+200);
//            ChartVo chartVo = new ChartVo((i+"月"),n);
//            chartVos.add(chartVo);
//        }
//        return ResultData.ok().data(chartVos);

        return propertyOverviewService.propertyPayCost(way,2);
    }

    @RequestMapping(value = "/DeviceErrorCauseAnalysis" , method = RequestMethod.POST)
    @ApiOperation(value = "设备报错原因分析",notes = "设备报错原因分析",produces="蒋翔", response = ResultData.class)
    public ResultData DeviceErrorCauseAnalysis (){
        ArrayList<ErrorCauseAnalysisVo> errorCauseAnalysisVos = new ArrayList<>();
        ErrorCauseAnalysisVo causeAnalysisVo = new ErrorCauseAnalysisVo("工厂用电", 1000, 0.98);
        ErrorCauseAnalysisVo causeAnalysisVo1 = new ErrorCauseAnalysisVo("工厂用煤", 950, 0.88);
        ErrorCauseAnalysisVo causeAnalysisVo2 = new ErrorCauseAnalysisVo("员工充电", 850, 0.65);
        ErrorCauseAnalysisVo causeAnalysisVo3 = new ErrorCauseAnalysisVo("日常照明", 750, 0.55);
        ErrorCauseAnalysisVo causeAnalysisVo4 = new ErrorCauseAnalysisVo("设备未关", 650, 0.48);
        ErrorCauseAnalysisVo causeAnalysisVo5 = new ErrorCauseAnalysisVo("光伏发电", 600, 0.40);
        errorCauseAnalysisVos.add(causeAnalysisVo);
        errorCauseAnalysisVos.add(causeAnalysisVo1);
        errorCauseAnalysisVos.add(causeAnalysisVo2);
        errorCauseAnalysisVos.add(causeAnalysisVo3);
        errorCauseAnalysisVos.add(causeAnalysisVo4);
        errorCauseAnalysisVos.add(causeAnalysisVo5);
        return ResultData.ok().data(errorCauseAnalysisVos);
    }

    @RequestMapping(value = "/DeviceErrorCount" , method = RequestMethod.POST)
    @ApiOperation(value = "设备报错次数统计",notes = "设备报错次数统计",produces="蒋翔", response = ResultData.class)
    private ResultData DeviceErrorCount(Integer way){
//        ArrayList<ChartVo> chartVos = new ArrayList<>();
//        for(int i=1 ; i< 13 ; i++){
//            int n = (int)(Math.random()*901+200);
//            ChartVo chartVo = new ChartVo((i+"月"),n);
//            chartVos.add(chartVo);
//        }
//        return ResultData.ok().data(chartVos);
        return propertyOverviewService.deviceErrorCount(way);
    }






}
